import utils from "../utils";
// import { domain } from "./domainConfig";
import devConfig from "../config.dev";
import releaseConfig from "../config.release";
import prodConfig from "../config.prod";
import { message } from 'antd';
const host = location.host;
let domain = "http://39.105.63.167/v1";
// if(utils.invalid.devHostReg.test(host)){//根据不同域名请求不同地址。
// 	domain = devConfig.domain;
// }else if(utils.invalid.prodHostReg.test(host)){
// 	domain = prodConfig.domain;
// }else {
// 	domain = releaseConfig.domain;
// }

// const domain = isDev?"http://192.168.1.61:8082":"http://121.196.201.219:8082";


// const domain = isDev?"http://192.168.1.21:8082":"https://crm-api.doukor.com:8082";
// window.uploadUrl = isDev?"http://192.168.1.21:8083":"https://crm-file.doukor.com:8083"; //图片上传的地址
// window.uploadUrls = isDev?"http://192.168.1.21:8082":"https://crm-api.doukor.com:8082";  //文件上传的地址
// window.websocketUrl = isDev?"wss://192.168.1.21:8090":"wss://crm-api.doukor.com:8090"

if (!Array.from) {
	Array.from = function (el) {
		return Array.apply(this, el);
	}
}

window.ajax = (url, param = {}, type = "post", isHeader = true) => {  //isHeader  是否需要header，高德地图请求不能带header，否则会报错
	// if(type === "get"){
	// 	Object.keys(param).forEach(key => paramsArray.push(key + '=' + param[key]));
	url = (url.indexOf("http") >= 0 ? url : domain + url);
	// 	if (url.search(/\?/) === -1) {
	// 		url += '?' + paramsArray.join('&')
	// 	} else {
	// 		url += '&' + paramsArray.join('&')
	// 	}
	// }
	return $.ajax({
		url,
		type: type,
		dataType: "json",
		beforeSend: () => {
		},
		headers: {	
			"Content-Type": "application/json;"
		},
		data: type == "post" ? JSON.stringify(param) : param,
	}).then((data = {}) => {
		return data;
	})
}
window.screenWidth=document.body.offsetWidth;
window.screenSm = screenWidth <= 768;